<template>
  <div class="number-allocation">
    <div class="header">
      <el-button type="info" style="background-color: #6e767c" @click="router.push('/nav')">回主页</el-button>
    </div>
    <h2>我的配号记录</h2>
    <div style="font-size: 18px; color: #000">总数：{{tableData.length}}</div>
    <div style="padding: 0 12px; margin-top: 12px">
      <el-table
          class="my-table"
          :data="tableData"
          style="width: 100%"
      >
        <el-table-column label="生肖" property="billType" width="60">
          <template #default="scope">{{ scope.row.billType === 0 ? '龙钞' : '蛇钞' }}</template>
        </el-table-column>
        <el-table-column property="serialNumber" label="冠字号"/>
        <el-table-column label="操作" width="120">
          <template #default="scope">
            <el-button style="width: 72px; height: 28px !important;" type="primary" @click="record = scope.row; detailModalVisible = true">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <van-popup v-model:show="detailModalVisible" closeable :close-on-click-overlay="false" round style="width: calc(100% - 12px); padding: 0 12px">
      <h2 style="display: flex">详细信息</h2>
      <div class="detail_box">
        <div>
          <div class="label">我的生肖：</div>
          <div class="value">{{record.billType === 0 ? '龙' : '蛇'}}钞</div>
        </div>
        <div>
          <div class="label">我的冠字号：</div>
          <div class="value">{{record.serialNumber}}</div>
        </div>
        <div>
          <div class="label">我的分类：</div>
          <div class="value">
            {{formatNumberType(record.numberType)}}
            <span>{{formatType(record.nakedOrGraded)}}</span>
            &nbsp;&nbsp;
            <span>{{record.gradedScore}}</span>
          </div>
        </div>
        <div>
          <div class="label">对方分类：</div>
          <div class="value">
            {{formatNumberType(record.otherNumberType)}}
            <span>{{formatType(record.otherNakedOrGraded)}}</span>
            &nbsp;&nbsp;
            <span>{{record.otherGradedScore}}</span>
          </div>
        </div>
        <div>
          <div class="label">配号时间：</div>
          <div class="value">{{record.peiTime}}</div>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script setup>
import router from "@/router";
import {ref} from "vue";
import {getMatching} from "@/api/api";
const tableData = ref([
])
const detailModalVisible = ref(false)
const record = ref({})

const formatNumberType = (type) =>{
  switch (type) {
    case -1:
      return '全部'
    case 0:
      return '单张'
    case 1:
      return '标十'
    case 2:
      return '标百'
    case 3:
      return '连续号'
  }
}

const formatType = (coinsType) =>{
  switch (coinsType) {
    case 0:
      return '裸币'
    case 1:
      return 'ACG'
    case 2:
      return 'PMG'
    case 3:
      return 'PCGS'
  }
}
function getList(){
  getMatching().then(res =>{
    tableData.value = res.rows
    console.log(res)
  })
}
getList()
</script>

<style lang="less">
.number-allocation {
  height: 100%;

  .header {
    display: flex;
    padding: 12px;
    box-shadow: 0 10px 15px -5px rgba(0,0,0,0.12);
  }

  .detail_box {
    & > div {
      display: flex;
      font-size: 18px;
      color: #000;
      margin-bottom: 12px;

      .label {
         font-weight: bold;
      }
    }
  }

  .my-table {
    td .el-button > span {
      font-size: 13px !important;
    }

    .el-button--primary {
      background-color: #1677ff !important;
    }
  }

  .el-table th.el-table__cell {
    background-color: #1677ff !important;
    color: #ffffff !important;
  }

  .el-table__header-wrapper {
    border-radius: 8px 8px 0 0;
  }
}
</style>
